@extends("admin::layouts.master")


@section("content")

    <div class="col-lg-12">
        <div class="card card-table">
            <div class="card-header">
                用户管理
                <div class="mt-2">

                    <button type="button" class="btn btn-primary">
                        用户列表
                    </button>
                    <button data-toggle="modal" data-target="#formuser" type="button" class="btn btn-primary">
                        添加用户
                    </button>


                    @component("components.modal",['title'=>'添加用户','url'=>'/admin/adminuser','id'=>'formuser'])

                        <div class="form-group">
                            <label>登录账号</label>
                            <input type="text" placeholder="请输入账号" name="name" class="form-control">
                        </div>
                        <div class="form-group">
                            <label>用户昵称</label>
                            <input type="text" placeholder="请输入后台用户昵称..." name="nickname" class="form-control">
                        </div>
                        <div class="form-group">
                            <label>登录密码</label>
                            <input type="password" required="required" placeholder="请输入后台用户登录密码..." name="password" class="form-control">
                        </div>

                    @endcomponent


                </div>
            </div>
            <div class="card-body">
                <table class="table table-sm table-striped">
                    <thead>
                    <tr>
                        <th>编号</th>
                        <th>昵称</th>
                        <th>账号</th>
                        <th>创建时间</th>
                        <th>操作</th>
                    </tr>
                    </thead>
                    <tbody>
                    @foreach($admins as $v)
                        <tr>
                            <td>{{$v["id"]}}</td>
                            <td>{{$v['name']}}</td>
                            <td>{{$v['nickname']}}</td>
                            <td>{{$v['created_at']}}</td>
                            <td>
                                <button data-toggle="modal" data-target="#edituser{{$v['id']}}" type='button' class="btn btn-primary">
                                    编辑
                                </button>


                                <form style="display: inline" action="/admin/adminuser/{{$v['id']}}" method="post">
                                    @csrf
                                    @method('DELETE')
                                    <button  class="btn btn-success">
                                        删除
                                    </button>
                                </form>


                                <a href="{{route('showrole',$v['id'])}}" class="btn btn-dark">分配角色</a>



                                @component("components.modal",['title'=>'编辑用户','url'=>'/admin/adminuser/'.$v['id'],'id'=>'edituser'.$v['id'],'method'=>'PUT'])

                                    <div class="form-group">
                                        <label>修改账号</label>
                                        <input type="text" value='{{$v['name']}}' name="name" class="form-control">
                                    </div>
                                    <div class="form-group">
                                        <label>修改昵称</label>
                                        <input type="text" value="{{$v['nickname']}}" name="nickname" class="form-control">
                                    </div>
                                    <div class="form-group">
                                        <label>修改密码</label>
                                        <input type="password" placeholder="请输入新密码" name="password" class="form-control">
                                    </div>

                                @endcomponent
                            </td>
                        </tr>
                    @endforeach
                    </tbody>
                </table>
            </div>
        </div>


        {{$admins->links()}}

    </div>


@stop